package com.cchr.acms.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cchr.acms.dao.ChapterDao;
import com.cchr.acms.model.Chapter;
import com.cchr.acms.service.ChapterService;

@Service
public class ChapterServiceImpl implements ChapterService {
	@Autowired
	private ChapterDao chapterDao;

	@Override
	public List<Chapter> queryChapter(Chapter chapter, int recordIndex, int pageNum) {
		Map paramMap=new HashMap();
		paramMap.put("country", chapter.getCountry());
		paramMap.put("states", chapter.getStates());
		paramMap.put("city", chapter.getCity());
		paramMap.put("chapter", chapter.getChapter());
		paramMap.put("recordIndex", recordIndex);
		paramMap.put("pageNum", pageNum);
		return chapterDao.queryChapter(paramMap);
	}

	@Override
	public List<Chapter> getAllChapter() {
		return chapterDao.getAllChapter();
	}

	@Override
	public int queryChapterCount(Chapter chapter) {
		Map<String, String> paramMap=new HashMap<String, String>();
		paramMap.put("country", chapter.getCountry());
		paramMap.put("states", chapter.getStates());
		paramMap.put("city", chapter.getCity());
		paramMap.put("chapter", chapter.getChapter());
		return chapterDao.queryChapterCount(paramMap);
	}

	@Override
	public int insertChapter(Chapter chapter) {
		return chapterDao.insertChapter(chapter);
	}

	@Override
	public int deleteChapter(int id) {
		return chapterDao.deleteChapter(id);
	}

	@Override
	public List<Chapter> queryAllChapter(Chapter chapter) {
		Map<String, String> paramMap=new HashMap<String, String>();
		paramMap.put("country", chapter.getCountry());
		paramMap.put("states", chapter.getStates());
		paramMap.put("city", chapter.getCity());
		paramMap.put("chapter", chapter.getChapter());
		return chapterDao.queryAllChapter(paramMap);
	}

	@Override
	public Chapter queryChapterById(int chapterId) {
		return chapterDao.queryChapterById(chapterId);
	}

	@Override
	public int updateChapter(Chapter chapter) {
		return chapterDao.updateChapter(chapter);
	}

	@Override
	public List<String> queryAllCountries() {
		return chapterDao.queryAllCountries();
	}

}
